package com.cloudeye.logtest.amqp;

import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lafangyuan on 2020/11/20.
 */
@Component
@EnableRabbit
public class RabbitMQService {

    @Bean
    public Queue queue(){
        Map<String,Object> map = new HashMap<>();
        //设置最大长度
        map.put("x-max-length",5);
        //设置死信路由
        map.put("x-dead-letter-exchange","my-dead-exchange");
        map.put("x-dead-letter-routing-key","dead-r-5");
        return new Queue("5-length",false,false,false,map);
    }

//    @Bean
    public Exchange deadExchange(){
        Exchange deadExchange = new TopicExchange("my-dead-exchange");
        return deadExchange;
    }

}
